package com.wdg.controller;

import com.wdg.fegin.IAroundFegin;
import com.wdg.pojo.Advert;
import com.wdg.pojo.Topic;
import com.wdg.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("around_consumer")
public class AroundController {

    @Autowired
    private IAroundFegin aroundFegin;

    @PostMapping("/uploadTopic")
    public boolean uploadTopic(@RequestBody Topic topic){
        return aroundFegin.uploadTopic(topic);
    }

    @GetMapping("/getTopic/{page}")
    public List<Topic> getTopic(@PathVariable("page") int page){
        return aroundFegin.getTopic(page);
    }

    //登录
    @PostMapping("/login")
    public User login(@RequestBody User user){
        return aroundFegin.login(user);
    }
    //注册
    @PostMapping("/regist")
    public boolean regist(@RequestBody User user){
        return aroundFegin.regist(user);
    }

    //广告
    @GetMapping("/getAllAdvert")
    public List<Advert> getAllAdvert(){
        return aroundFegin.getAllAdvert();
    }
    @GetMapping("getAllUser")
    public List<User> getAllUser(@RequestParam("page") int page){
        return aroundFegin.getAllUser(page);
    }

    //关注
    @GetMapping("/focus")
    public boolean focus(@RequestParam("uid") int uid, @RequestParam("uided") int uided){
        return aroundFegin.focus(uid,uided);
    }
    //取消关注
    @GetMapping("/delfocus")
    public boolean delfocus(@RequestParam("uid") int uid, @RequestParam("uided") int uided){
        return aroundFegin.delfocus(uid,uided);
    }
    //判断是否关注
    @GetMapping("/isfocus")
    public boolean isfocus(@RequestParam("uid") int uid, @RequestParam("uided") int uided){
        return aroundFegin.isfocus(uid,uided);
    }

    //收藏
    @GetMapping("/staroff")
    public boolean staroff(@RequestParam("uid") int uid, @RequestParam("cbid") String cbid){
        return aroundFegin.staroff(uid,cbid);
    }
    //取消收藏
    @GetMapping("/delstaroff")
    public boolean delstaroff(@RequestParam("uid") int uid, @RequestParam("cbid") String cbid){
        return aroundFegin.delstaroff(uid,cbid);
    }
    //判断是否收藏
    @GetMapping("/isstaroff")
    public boolean isstaroff(@RequestParam("uid") int uid, @RequestParam("cbid") String cbid){
        return aroundFegin.isstaroff(uid,cbid);
    }

}
